<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets" 
      xmlns:p="http://primefaces.prime.com.tr/ui" 
      xmlns:f="http://java.sun.com/jsf/core">

    <ui:composition template="./WEB-INF/faces/newTemplate.xhtml">
        <ui:param name="title_text" value="Add Product" />
        <ui:param name ="headText" value ="Add Product" />
        <ui:define name="content">
            
            <h:form rendered="#{userSessionBean.loggedIn}">
                <p:panel id="productMessages" styleClass="pfPanel">
                    <!-- Product name -->
                    <h:outputLabel value="model:" /> 
                    <h:inputText title="Model" id="productName" value="#{addProductBackingBean.prodName}">
                        <f:ajax event="blur" render="productNameMessage"/>
                    </h:inputText>
                    <br/>
                    <p:message id="productNameMessage" for="productName"/>
                    <br/>

                    <!-- Product category -->
                    <h:outputLabel value="make:" />
                    <h:inputText title="Make" id="productCategory"
                                 value="#{addProductBackingBean.catName}">
                        <f:ajax event="blur" render="productCategoryMessage"/>
                    </h:inputText><br/>
                    <p:message id="productCategoryMessage" for="productCategory"/><br/>

                    <!-- Product price -->
                    <h:outputLabel value="price:" />
                    <h:inputText title="Price" id="productPrice"
                                 value="#{addProductBackingBean.price}">
                        <f:ajax event="blur" render="productPriceMessage"/>
                    </h:inputText> <br/>
                    <p:message id="productPriceMessage" for="productPrice"/><br/>
                       <h:outputLabel value="year" />
                    <h:inputText title="Product year" id="productYear"
                                 value="#{addProductBackingBean.year}">
                        <f:ajax event="blur" render="productYearMessage"/>
                    </h:inputText> <br/>

                    <p:message id="productYearMessage" for="productYear"/><br/>
                    <h:outputLabel value="mileage" />
                    <h:inputText title="Product Mileage" id="productMileage"
                                 value="#{addProductBackingBean.mileage}">
                        <f:ajax event="blur" render="productMileageMessage"/>
                    </h:inputText> <br/>
                    <p:message id="productMileageMessage" for="productMileage"/><br/>
                    <p:growl id="messages" />
                </p:panel>
                <p:commandButton update="productMessages" value="Submit" action="#{addProductControllerBean.addProduct}"/>
            </h:form>
            <h:form rendered="#{!userSessionBean.loggedIn}">
                You are not logged in!
            </h:form>
        </ui:define>
    </ui:composition>

</html>

